package cn.virens.web.components.beetl.format;

import org.beetl.core.Format;

import com.alibaba.fastjson.JSON;

public class StatusFormat implements Format {

	@Override
	public Object format(Object data, String pattern) {
		if (data == null) { return null; }
		if (pattern == null) { return data; }
		switch (pattern) {
		case "json":
			return json(data);

		default:
			return "";
		}
	}

	private String json(Object data) {
		return JSON.toJSONString(data);
	}

}
